﻿<phone:PhoneApplicationPage
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:local="clr-namespace:SilverXNA" 
    xmlns:behaviour="clr-namespace:SlXnaApp1.Behaviours"
    behaviour:VisualStates.CurrentState="{Binding CurrentState, Mode=TwoWay}"
    x:Class="SilverXNA.GamePage"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    SupportedOrientations="Landscape" Orientation="Landscape"
    mc:Ignorable="d" d:DesignHeight="480" d:DesignWidth="800"
    shell:SystemTray.IsVisible="False"
	DataContext="{Binding Game, Source={StaticResource Locator}}">

	<Grid x:Name="ContentPanel">
		<VisualStateManager.VisualStateGroups>
			<VisualStateGroup x:Name="VisualStateGroup">
				<VisualStateGroup.Transitions>
					<VisualTransition GeneratedDuration="0:0:1">
						<VisualTransition.GeneratedEasingFunction>
							<CircleEase EasingMode="EaseOut"/>
						</VisualTransition.GeneratedEasingFunction>
					</VisualTransition>
				</VisualStateGroup.Transitions>
				<VisualState x:Name="GameRunning"/>
				<VisualState x:Name="DisplayWin">
					<Storyboard>
						<DoubleAnimation Duration="0" To="1" Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="winOverlayControl" d:IsOptimized="True"/>
						<DoubleAnimation Duration="0" To="0" Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.TranslateX)" Storyboard.TargetName="winOverlayControl" d:IsOptimized="True"/>
					</Storyboard>
				</VisualState>
				<VisualState x:Name="DisplayLose">
					<Storyboard>
						<DoubleAnimation Duration="0" To="0" Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.TranslateX)" Storyboard.TargetName="loseOverlayControl" d:IsOptimized="True"/>
						<DoubleAnimation Duration="0" To="1" Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="loseOverlayControl" d:IsOptimized="True"/>
					</Storyboard>
				</VisualState>
				<VisualState x:Name="DisplayDied">
					<Storyboard>
						<DoubleAnimation Duration="0" To="0" Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.TranslateX)" Storyboard.TargetName="diedOverlayControl" d:IsOptimized="True"/>
						<DoubleAnimation Duration="0" To="1" Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="diedOverlayControl" d:IsOptimized="True"/>
					</Storyboard>
				</VisualState>
			</VisualStateGroup>
		</VisualStateManager.VisualStateGroups>
		<Grid.ColumnDefinitions>
			<ColumnDefinition Width="0.1*" />
			<ColumnDefinition Width="0.9*" />
		</Grid.ColumnDefinitions>
		<Grid.RowDefinitions>
			<RowDefinition Height="0.083*" />
			<RowDefinition Height="0.917*" />
		</Grid.RowDefinitions>
		<TextBlock x:Name="TimeLabel"
				   Text="Time Left: "
				   Foreground="{Binding GameTimeDisplayColor}"
				   TextWrapping="Wrap"
				   Margin="12,12,20,0"
				   d:LayoutOverrides="Width, Height" />
		<TextBlock x:Name="TimeValue"
				   Text="{Binding GameTimeString}"
				   Foreground="{Binding GameTimeDisplayColor}"
				   TextWrapping="Wrap"
				   Margin="12,12,20,0"
				   d:LayoutOverrides="Width, Height"
				   Grid.Column="1" />
		<TextBlock x:Name="ScoreLabel"
				   Text="Score: "
				   HorizontalAlignment="Left"
				   TextWrapping="Wrap"
				   Margin="12,12,0,0"
				   d:LayoutOverrides="Height"
				   Foreground="Yellow"
				   Grid.Row="1" />
		<TextBlock x:Name="ScoreValue"
				   Text="{Binding GameScore}"
				   HorizontalAlignment="Left"
				   TextWrapping="Wrap"
				   Margin="12,12,0,0"
				   Foreground="Yellow"
				   Grid.Row="1"
				   d:LayoutOverrides="Height"
				   Grid.Column="1" />
		<local:WinOverlayControl x:Name="winOverlayControl" Grid.ColumnSpan="2" Grid.Row="1" Opacity="0" RenderTransformOrigin="0.5,0.5" >
			<local:WinOverlayControl.RenderTransform>
				<CompositeTransform TranslateX="-800"/>
			</local:WinOverlayControl.RenderTransform>
		</local:WinOverlayControl>
		<local:LoseOverlayControl x:Name="loseOverlayControl" Grid.ColumnSpan="2"
								  Grid.Row="1" RenderTransformOrigin="0.5,0.5" Opacity="0" >
			<local:LoseOverlayControl.RenderTransform>
				<CompositeTransform TranslateX="-800"/>
			</local:LoseOverlayControl.RenderTransform>
		</local:LoseOverlayControl>
		<local:DiedOverlayControl x:Name="diedOverlayControl" Grid.ColumnSpan="2"
								  Grid.Row="1" RenderTransformOrigin="0.5,0.5" Opacity="0" >
			<local:DiedOverlayControl.RenderTransform>
				<CompositeTransform TranslateX="-800"/>
			</local:DiedOverlayControl.RenderTransform>
		</local:DiedOverlayControl>
	</Grid>

	<!--No XAML content is required as the page is rendered entirely with the XNA Framework-->

</phone:PhoneApplicationPage>
